package com.terrorism.sdk.view;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.terrorism.sdk.R;

/**
 * @since Monday, June 02, 2014
 * @author hoangcaomobile
 *
 */
public class CustomToast {

	// toast short
	public static void vToastShort(Activity activity, String msg) {
		View layout = activity.getLayoutInflater().inflate(R.layout.ui_toast, null);
		TextView text = (TextView) layout.findViewById(R.id.tvToast);
		text.setText(msg);
		Toast toast = new Toast(activity);
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.setDuration(Toast.LENGTH_SHORT);
		toast.setView(layout);
		toast.show();
	}
	// --

	// toast long
	public static void vToastLong(Activity activity, String msg) {
		View layout = activity.getLayoutInflater().inflate(R.layout.ui_toast, null);
		TextView text = (TextView) layout.findViewById(R.id.tvToast);
		text.setText(msg);
		Toast toast = new Toast(activity);
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.setView(layout);
		toast.show();
	}
	// --

	// toast notification cannot connect to server
	public static void vToastCannotConnectToServer(Activity activity) {
		vToastShort(activity, activity.getString(R.string.toastErrorCannotConnectToServer));
	}
	// --

	// toast notification no internet connection
	public static void vToastNoInternet(Activity activity) {
		vToastShort(activity, activity.getString(R.string.toastErrorNoInternet));
	}
	// --

	// toast notification SD card not OK
	public static void vToastSDCardNotOK(Activity activity) {
		vToastShort(activity, activity.getString(R.string.toastErrorSDCard));
	}
	// --

	public static void vToastErrorGeneral(Activity activity) {
		vToastShort(activity, activity.getString(R.string.toastErrorGeneral));
	}

}
